﻿using B.S.Data.MES.API.Applications.CangKu.Command;
using B.S.Domain.CangKu;
using B.S.Infratrctrue;
using B.S.Requst;
using MediatR;

namespace B.S.Data.MES.API.Applications.CangKu.CommandHandlers
{
    public class PlDeleChuweiCommandHandlers : IRequestHandler<PlChuWeiCommand, APIRequst<int>>
    {
        private readonly IBaseRepository<ChuWei> chuRepository;
        public PlDeleChuweiCommandHandlers(IBaseRepository<ChuWei> chuRepository)
        {
            this.chuRepository = chuRepository;
        }

        public Task<APIRequst<int>> Handle(PlChuWeiCommand request, CancellationToken cancellationToken)
        {
           
             var pa = chuRepository.GetAll().Where(x => request.Ids.Contains(x.ChuId)).ToList();
            foreach (var p in pa) 
            {
                p.isDel= true;
            }
            chuRepository.UpdateRange(pa);
            return Task.FromResult(new APIRequst<int> 
            {
                Code = RequstCode.成功,
                Msg = RequstCode.成功.ToString()
            });
        }
    }
}
